var path = "";

//点击事件
function dataClick(Cname, name, type) {
    // $(".title").css('display',"block");
    $(".detailedInfo").css({
        "display": "block",
        "position": "fixed",
        "top": "0px",
        "left": "0px",
        "height": "100%"
    });
    getData(Cname,name, type, 10);
}

//鼠标悬停事件
function dataOver(Cname,name, type) {
    getData(Cname,name, type, 1);
    $(".detailedInfo").css({
        "display": "block",
        "position": "absolute",
        "top": "410px",
        "left": "0px",
        "height": "auto"
    });
    // $(".title").css('display',"none");
}

//鼠标移出事件
function leave () {
    $(".detailedInfo").css("display", "none")
}

//查询接口
function getData(Cname,name, type, limit) {
    $(".detailedInfoTable").html("")
    $(".title").html(Cname+"<p onclick='leave();' style='float: right;cursor: pointer;'>❌</p>")
    $.ajax({
        url: path + "/ai/dataSummary/getDataSummaryList",
        data: {name: name, type: type, page: 1, limit: limit},
        type: "get",
        async: true,
        success: function (data) {
            var div = "";
            $(".detailedInfoTable").html(div);
            if (data.code == 0 || data.code == 200) {
                data = data.data;
                if (name.indexOf('Oxidation_fan') != -1 || name.indexOf("Absorber_agitator") != -1 || name.indexOf("Gypsum_discharge_pump") != -1 || type == 0) {//氧化风机  吸收塔侧搅拌器  石膏排出泵
                    div += "<table><tr><td>id</td><td>地址</td><td>百分比</td>" +
                        "<td>不平衡</td><td>电机当前停机时间</td>" +
                        "<td>电动机保护器</td><td>汽车运行状态</td><td>引擎信息</td>" +
                        "<td>相电流A</td><td>相电流B</td><td>相电流C</td>" +
                        "<td>功率因数</td><td>三相活动电源</td><td>时间</td>" +
                        "<td>总数</td><td>电机总运行时间</td>";
                } else {
                    div += "<table><tr><td>id</td><td>地址</td><td>环境温度</td><td>设备类型名称</td>" +
                        "<td>估计电机温度</td><td>接地故障</td><td>最后一小时</td><td>电机电流</td>" +
                        "<td>引擎阶段</td><td>输出频率</td><td>电源相位规格</td>" +
                        "<td>先前的</td><td>罗斯塔图斯</td><td>运行时计数</td>" +
                        "<td>温度</td><td>时间</td><td>振动马达</td><td>振动泵</td>";
                }
                if (name.indexOf('Oxidation_fan') != -1 || name.indexOf("Absorber_agitator") != -1 || name.indexOf("Gypsum_discharge_pump") != -1) {//氧化风机  吸收塔侧搅拌器  石膏排出泵
                    div += "</tr>";
                    for (var i = 0; i < data.length; i++) {
                        div += "<tr><td>" + data[i].id + "</td><td>" + data[i].address + "</td>" +
                            "<td>" + data[i].averagePhaseCurrent + "</td>" +
                            "<td>" + data[i].currentImbalance + "</td>" +
                            "<td>" + data[i].currentShutdownTimeOfMotor + "</td>" +
                            "<td>" + data[i].motorProtectorName + "</td><td>" + data[i].motorRunningState + "</td>" +
                            "<td>" + data[i].motorTripInformation + "</td><td>" + data[i].phaseACurrent + "</td>" +
                            "<td>" + data[i].phaseBCurrent + "</td><td>" + data[i].phaseCCurrent + "</td>" +
                            "<td>" + data[i].powerFactor + "</td><td>" + data[i].threePhaseActivePower + "</td>" +
                            "<td>" + data[i].time + "</td><td>" + data[i].totalNumberOfStops + "</td>" +
                            "<td>" + data[i].totalRunningTimeOfMotor + "</td>" +
                            "</tr>"
                    }
                    div += "</table>";
                } else if (type == 0) { //马达保护器
                    div += "<td>温度</td><td>振动马达</td><td>振动泵</td></tr>";
                    for (var i = 0; i < data.length; i++) {
                        div += "<tr><td>" + data[i].id + "</td><td>" + data[i].address + "</td>" +
                            "<td>" + data[i].averagePhaseCurrent + "</td>" +
                            "<td>" + data[i].currentImbalance + "</td>" +
                            "<td>" + data[i].currentShutdownTimeOfMotor + "</td>" +
                            "<td>" + data[i].motorProtectorName + "</td><td>" + data[i].motorRunningState + "</td>" +
                            "<td>" + data[i].motorTripInformation + "</td><td>" + data[i].phaseACurrent + "</td>" +
                            "<td>" + data[i].phaseBCurrent + "</td><td>" + data[i].phaseCCurrent + "</td>" +
                            "<td>" + data[i].powerFactor + "</td><td>" + data[i].threePhaseActivePower + "</td>" +
                            "<td>" + data[i].time + "</td><td>" + data[i].totalNumberOfStops + "</td>" +
                            "<td>" + data[i].totalRunningTimeOfMotor + "</td><td>" + data[i].temperature + "</td>" +
                            "<td>" + data[i].vibrMotor + "</td><td>" + data[i].vibrPump + "</td>" +
                            "</tr>"
                    }
                    div += "</table>";
                } else if (type == 1) {// 变频器
                    for (var i = 0; i < data.length; i++) {
                        div += "<tr><td>" + data[i].id + "</td><td>" + data[i].address + "</td>" +
                            "<td>" + data[i].ambientTemperature + "</td><td>" + data[i].equipmentName + "</td>" +
                            "<td>" + data[i].estimatedMotorTemperature + "</td><td>" + data[i].groundFault + "</td>" +
                            "<td>" + data[i].lastHourKWh + "</td><td>" + data[i].motorCurrent + "</td>" +
                            "<td>" + data[i].motorPhaseLoss + "</td><td>" + data[i].outputFrequency + "</td>" +
                            "<td>" + data[i].powerSupplyPhaseFailure + "</td><td>" + data[i].previousDayKWH + "</td>" +
                            "<td>" + data[i].roStatus + "</td><td>" + data[i].runTimeCount + "</td>" +
                            "<td>" + data[i].temperature + "</td><td>" + data[i].time + "</td>" +
                            "<td>" + data[i].vibrMotor + "</td><td>" + data[i].vibrPump + "</td>" +
                            "</tr>"
                    }
                    div += "</table>";
                }
                $(".detailedInfoTable").html(div);
            } else {
                layer.alert(data.msg);
            }
        },
    });
}